const jsons = require('./dist/images/imgListInfo.json');
const Koa = require('koa');
const Router = require('koa-router');
const bodyParser = require('koa-bodyparser');

const app = new Koa();
const router = new Router();

app.use(async (ctx, next) => {
  ctx.set('Access-Control-Allow-Origin', "*");
  ctx.set('Access-Control-Allow-Headers', 'content-type');
  ctx.set('Access-Control-Allow-Methods', 'OPTIONS,GET,HEAD,PUT,POST,DELETE,PATCH')
  await next();
});

router.get('/get', (context, next)=> {
    context.body = jsons;
  })

app.use(bodyParser());
app.use(router.routes()).use(router.allowedMethods());
app.listen(3001, () => console.log('server listen on 3001'))